#! /bin/bash

## expath-pkg --help
##
## Frontend script for org.expath.pkg.saxon.PackageManager.
##
## Depends on the following environment variables:
##
##   - EXPATH_REPO
##   - EXPATH_PKG_JAR
##   - JAVA_HOME
##   - ...


# the EXPath Packaging for Saxon's Jar file
# TODO: If not set, should be an error.
if [[ -z "$EXPATH_PKG_JAR" ]]; then
    echo EXPATH_PKG_JAR is not set.  Bye.
    exit 1;
fi

# the Java virtual machine
if [[ -z "$JAVA_HOME" ]]; then
    JAVA=java
else
    JAVA=${JAVA_HOME}/bin/java
fi

# # the classpath delimiter depends on the system
# if uname | grep -i cygwin >/dev/null 2>&1; then
#     CP_DELIM=";"
# else
#     CP_DELIM=":"
# fi

# # error if SAXON_HOME is not set
# if [[ -z "$SAXON_HOME" ]]; then
#     echo SAXON_HOME is not set.  Bye.
#     exit 1;
# fi

# # the classpath
# CP="${EXPATH_PKG_JAR}${CP_DELIM}${SAXON_HOME}/saxon9.jar${CP_DELIM}${SAXON_HOME}/saxon9-s9api.jar"

# # the actual command
# "$JAVA" -cp "$CP" org.expath.pkg.saxon.PackageManager "$@"

# the actual command
"$JAVA" -cp "${EXPATH_PKG_JAR}" org.expath.pkg.saxon.PackageManagerTextUI "$@"
